﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using WalkingTec.Mvvm.Core;
using System.Text.Json.Serialization;
using nERP.Model;
using nERP.Model.Po;
using nERP.Model.Bas;
using nERP.Model.Wms;

namespace nERP.Model.Po
{
    /// <summary>
    /// 采购明细
    /// </summary>
	[Table("BuyDetail")]
    [SoftKey(nameof(BuyDetail.BuyDetailCode))]
    [Display(Name = "_Model.BuyDetail")]
    public class BuyDetail : BasePoco, ITenant
    {
        [Display(Name = "_Model._BuyDetail._Seq")]
        [Comment("序号")]
        public int? Seq { get; set; }
        [Display(Name = "_Model._BuyDetail._Buy")]
        [Comment("采购")]
        [NotMapped]
        public Buy Buy { get; set; }
        [Display(Name = "_Model._BuyDetail._Buy")]
        [StringLength(32, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("采购")]
        public string BuyId { get; set; }
        [Display(Name = "_Model._BuyDetail._BuyDetailCode")]
        [StringLength(32, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("购货明细单号")]
        [Required(ErrorMessage = "Validate.{0}required")]
        [CanNotEdit]
        public string BuyDetailCode { get; set; }
        [Display(Name = "_Model._BuyDetail._Goods")]
        [Comment("商品")]
        [NotMapped]
        public Goods Goods { get; set; }
        [Display(Name = "_Model._BuyDetail._Goods")]
        [StringLength(32, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Required(ErrorMessage = "Validate.{0}required")]
        [Comment("商品")]
        public string GoodsId { get; set; }
        [Display(Name = "_Model._BuyDetail._GoodsName")]
        [StringLength(64, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("商品名称")]
        public string GoodsName { get; set; }
        [Display(Name = "_Model._BuyDetail._GoodsSpec")]
        [StringLength(64, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("商品规格")]
        public string GoodsSpec { get; set; }
        [Display(Name = "_Model._BuyDetail._GoodsUnit")]
        [StringLength(32, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("商品单位")]
        public string GoodsUnit { get; set; }
        [Display(Name = "_Model._BuyDetail._BuyNumber")]
        [Required(ErrorMessage = "Validate.{0}required")]
        [Comment("数量")]
        public decimal? BuyNumber { get; set; }
        [Display(Name = "_Model._BuyDetail._UnitPrice")]
        [Required(ErrorMessage = "Validate.{0}required")]
        [Comment("购货单价")]
        public decimal? UnitPrice { get; set; }
        [Display(Name = "_Model._BuyDetail._DiscountPrice")]
        [Required(ErrorMessage = "Validate.{0}required")]
        [Comment("折扣金额")]
        public decimal? DiscountPrice { get; set; }
        [Display(Name = "_Model._BuyDetail._TotalPrice")]
        [Comment("金额")]
        public decimal? TotalPrice { get; set; }
        [Display(Name = "_Model._BuyDetail._TaxRate")]
        [Comment("税率")]
        public decimal? TaxRate { get; set; }
        [Display(Name = "_Model._BuyDetail._TaxUnitPrice")]
        [Comment("含税单价")]
        public decimal? TaxUnitPrice { get; set; }
        [Display(Name = "_Model._BuyDetail._TaxPrice")]
        [Comment("税额")]
        public decimal? TaxPrice { get; set; }
        [Display(Name = "_Model._BuyDetail._TotalTaxPrice")]
        [Comment("含税金额")]
        public decimal? TotalTaxPrice { get; set; }
        [Display(Name = "_Model._BuyDetail._Warehouse")]
        [Comment("仓库")]
        [NotMapped]
        public Warehouse Warehouse { get; set; }
        [Display(Name = "_Model._BuyDetail._Warehouse")]
        [StringLength(32, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("仓库")]
        public string WarehouseId { get; set; }
        [Display(Name = "_Model._BuyDetail._Status")]
        [Comment("状态")]
        public dStatusTypeEnum? Status { get; set; } = dStatusTypeEnum.Unaudited;
        [Display(Name = "_Model._BuyDetail._Remark")]
        [StringLength(256, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("备注")]
        public string Remark { get; set; }
        [Display(Name = "_Model._BuyReturnDetail._BuyDatail")]
        [InverseProperty("BuyDatail")]
        [NotMapped]
        [SoftFK(nameof(nERP.Model.Po.BuyReturnDetail.BuyDatailId))]
        public List<BuyReturnDetail> BuyReturnDetail_BuyDatail { get; set; }
        [Display(Name = "_Model._BuyInWarehouseDetail._BuyDetail")]
        [InverseProperty("BuyDetail")]
        [NotMapped]
        [SoftFK(nameof(nERP.Model.Wms.BuyInWarehouseDetail.BuyDetailId))]
        public List<BuyInWarehouseDetail> BuyInWarehouseDetail_BuyDetail { get; set; }
        [Display(Name = "_Model._BuyReturnOutWarehouseDetail._BuyDetail")]
        [InverseProperty("BuyDetail")]
        [NotMapped]
        [SoftFK(nameof(nERP.Model.Wms.BuyReturnOutWarehouseDetail.BuyDetailId))]
        public List<BuyReturnOutWarehouseDetail> BuyReturnOutWarehouseDetail_BuyDetail { get; set; }
        [StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
        public string TenantCode { get; set; }

    }

}
